package com.ruoyi.web.controller.assets;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.RepairAudit;
import com.ruoyi.system.service.IRepairAuditService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 报修审核Controller
 * 
 * @author hzl
 * @date 2025-03-18
 */
@RestController
@RequestMapping("/assets/repairAudit")
public class RepairAuditController extends BaseController
{
    @Autowired
    private IRepairAuditService repairAuditService;

    /**
     * 查询报修审核列表
     */
    @PreAuthorize("@ss.hasPermi('assets:repairAudit:list')")
    @GetMapping("/list")
    public TableDataInfo list(RepairAudit repairAudit)
    {
        startPage();
        List<RepairAudit> list = repairAuditService.selectRepairAuditList(repairAudit);
        return getDataTable(list);
    }

    /**
     * 导出报修审核列表
     */
    @PreAuthorize("@ss.hasPermi('assets:repairAudit:export')")
    @Log(title = "报修审核", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, RepairAudit repairAudit)
    {
        List<RepairAudit> list = repairAuditService.selectRepairAuditList(repairAudit);
        ExcelUtil<RepairAudit> util = new ExcelUtil<RepairAudit>(RepairAudit.class);
        util.exportExcel(response, list, "报修审核数据");
    }

    /**
     * 获取报修审核详细信息
     */
    @PreAuthorize("@ss.hasPermi('assets:repairAudit:query')")
    @GetMapping(value = "/{repairApplicationId}")
    public AjaxResult getInfo(@PathVariable("repairApplicationId") Long repairApplicationId)
    {
        return success(repairAuditService.selectRepairAuditByRepairApplicationId(repairApplicationId));
    }

    /**
     * 新增报修审核
     */
    @PreAuthorize("@ss.hasPermi('assets:repairAudit:add')")
    @Log(title = "报修审核", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody RepairAudit repairAudit)
    {
        return toAjax(repairAuditService.insertRepairAudit(repairAudit));
    }

    /**
     * 修改报修审核
     */
    @PreAuthorize("@ss.hasPermi('assets:repairAudit:edit')")
    @Log(title = "报修审核", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody RepairAudit repairAudit)
    {
        return toAjax(repairAuditService.updateRepairAudit(repairAudit));
    }

    /**
     * 删除报修审核
     */
    @PreAuthorize("@ss.hasPermi('assets:repairAudit:remove')")
    @Log(title = "报修审核", businessType = BusinessType.DELETE)
	@DeleteMapping("/{repairApplicationIds}")
    public AjaxResult remove(@PathVariable Long[] repairApplicationIds)
    {
        return toAjax(repairAuditService.deleteRepairAuditByRepairApplicationIds(repairApplicationIds));
    }
}
